package com.yc.java_basic2;

public class Test1 {
	public static void main(String[] args) {
		//1
		int sum = 0;
		for(int i = 1; i <= 99; i+=2) {
			sum += i;
		}
		System.out.println( sum );
		
		//2
		for(int i = 1; i <= 100; i++) {
			if( i % 7 == 0 && i % 2 == 0 ) {
				System.out.println( i );  
			}
		}
		
		//3      在java中,整型除以整型.,最终结果还是整型
		System.out.println( 1 / 2 );
		double sum3 = 0;
		double a = 1.0;
		double b = 1.0; 
		double temp = 0;
		for(int i = 1; i <= 20; i++) {
			if( i % 2 == 0 ) {	//偶数是减
				sum3 -= a / b;
			}else {
				sum3 += a / b;
			}
			//交换分子和分母
			temp = b;
			b = a + b;
			a = temp;
		}
		System.out.println( sum3 );
		
		//4  
		double sum4 = 0;
		for(int i = 1; i <= 50; i++) {
										//  a的b次幂
			sum4 += 1.0 / (2 * i - 1) * Math.pow(-1, i + 1);
		}
		System.out.println( sum4 );
	}
}
